#include "ThreadPool.hpp"
#include "Task.hpp"
#include <unistd.h>
#include <ctime>


int main()
{
    // ThreadPool<Task>* tp = new ThreadPool<Task>(5);
    // tp->Start();
    ThreadPool<Task>::GetInstance()->Start();
    srand((unsigned int)time(nullptr) ^ getpid());

    while(true)
    {
        // 1、构建任务
        int data1 = rand() % 10 + 1;
        usleep(10);
        int data2 = rand() % 10;
        char oper = opers[rand() % opers.size()];
        Task t(data1, data2, oper);
        //tp->Push(t);
        ThreadPool<Task>::GetInstance()->Push(t);
        
        // 2、把任务交给线程池处理
        cout << "main thread make task: " << t.GetTask() << endl;
        sleep(1);
    }

    return 0;
}